
fn testVariableDeclaration() {
    let a = 10;
    let b = 20;
    let c = a + b;
    print("a:", a);
    print("b:", b);
    print("c:", c);
}


fn testFunctionCall() {
    fn add(x, y) {
        return x + y;
    }
    let result = add(5, 7);
    print("add(5, 7):", result);
}


fn testForLoop() {
    for(let i = 0; i < 5; i++) {
        print("i:", i);
    }
}


fn testIfStatement() {
    let x = 10;
    if (x > 5) {
        print("x is greater than 5");
    } else {
        print("x is not greater than 5");
    }
}


fn testBitwiseOperations() {
    let a = 5; 
    let b = 3; 
    print("a & b:", a & b); 
    print("a | b:", a | b); 
    print("a ^ b:", a ^ b); 
    print("~a:", ~a);
    print("a << 1:", a << 1); 
    print("a >> 1:", a >> 1); 
}


fn testModuloOperation() {
    let a = 10;
    let b = 3;
    print("a % b:", a % b);
}


fn testBreakStatement() {
    for(let i = 0; i < 10; i = i + 1) {
        if (i == 5) {
            break;
        }
        print("i:", i);
    }
}

fn testArray(){
    let arr = [1,2,3,4,5,6];
    print(arr.length);
    print(arr[1]);
    let index = 2;
    print(arr[index-1]);
    arr[2]=100;
    print(arr);
}

fn testWhileStatement(){
    let i = 0;
    while(true){
        i=i+1;
        print("i:"+i);
        if(i>=5){
            break;
        }
    }
}

fn testIncrementAndDecrement(){
    let x = 15;
    print("x++:", x++);
    print("x:", x);
    print("++x:", ++x);
    print("x:", x);
    print("x--:", x--);
    print("x:", x);
    print("--x:", --x);
    print("x:", x);
    print("x+++1:", x+++1);
    print("x:", x);
    print("++x+1:", ++x+1);
    print("x:", x);
}

fn testObjectStatement(){
    let obj = {
        name:"steve",
        age:18
    };
    obj.name="steve2";
    obj.sex="male";

    print(obj);

}

fn testLogicalOperation(){
    let a = true;
    let b = false;
    print("a",a);
    print("b",b);
    print("a && b:", a && b);
    print("a || b:", a || b);
    print("!a:", !a);
    print("a!=b:", a!=b);
}

print("Running testVariableDeclaration:");
testVariableDeclaration();
print("Running testFunctionCall:");
testFunctionCall();
print("Running testForLoop:");
testForLoop();
print("Running testIfStatement:");
testIfStatement();
print("Running testBitwiseOperations:");
testBitwiseOperations();
print("Running testModuloOperation:");
testModuloOperation();
print("Running testBreakStatement:");
testBreakStatement();
print("Running testArrayOperation:");
testArray();
print("Running testWhileStatement:");
testWhileStatement();
print("Running testIncrementAndDecrement:");
testIncrementAndDecrement();
print("Running testObjectStatement:");
testObjectStatement();
print("Running testLogicalOperation:");
testLogicalOperation();
print("all test passed");

let str = " hello world";
print(str.trim());
print(str.charAt(1));


let a = {name:"steve"};

let b = {target:a};
b.target.age=18;
print(a);
print(b);

print(Math.random());

let func = (x,y)->{return x*y+5;};
let func2 = ()->{return 5;};
let obj = {
    name:"steve",
    age:18,
    setAge:(age)->{
        obj.age=age;
    }
};
print(func(2,3));
print(func2());
obj.setAge(20);
print(obj);

print((1+2+3*2+1));